package com.example.demo.service.impl;

import com.example.demo.service.UserServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;

/**
 * @author littlebadfox
 * @date 2022-04-23-22:11
 * @desc
 */
@Service
public class UserService implements UserServiceImpl {
    @Resource
    private RestTemplate restTemplate;

    @Override
    public String loginUserApi(String code){
        String appid="wx6e4e790fc377f388";
        String secret="c84513cf28514727d8bc3b90944ef8c4";
        String url="https://api.weixin.qq.com/sns/jscode2session?appid="+appid+"&secret="+secret+"&js_code="+code+"&grant_type=authorization_code";
        return restTemplate.getForObject(url,String.class);
    }
}
